
<div class="wrapper-main">
    <div class="headlabel"><?php echo $this->__("Search Results") ?></div>
        
        <div class="result-search">
            <h3><?php echo $this->__("Filtering") ?></h3>
            <div class="block block-layered-nav">
                <div class="sidebar-search clearfix">
                        <div class="search-by-category">
                            <div class="lblhead border-t-l-r"><h3><?php echo $this->__("Search Category") ?></h3></div>
                                <div class="content-category">
                                    <div class="jcrollbar">
                                       <?php
                                            $categoryList = Mage::getModel('catalog/category')
                                                ->getCollection()
                                                ->addAttributeToSelect('*')
                                                ->addIsActiveFilter()
                                                ->addLevelFilter(2)
                                         ?>
                                        <?php if(count($categoryList) > 1): ?>
                                            <ul>
                                                <?php foreach ($categoryList as $_cate): ?>
                                                <?php if($_cate->getId() != ROOT_CATEGORY): ?>

                                                    <?php $productCollection = $_cate->getProductCollection()
                                                                            ->joinField(
                                                                            'qty',
                                                                            'cataloginventory/stock_item',
                                                                            'qty',
                                                                            'product_id=entity_id',
                                                                            '{{table}}.stock_id=1',
                                                                            'left'
                                                                        )
                                                                        ->addAttributeToFilter('qty', array('gt' => 0)); ?>
                                                    <?php $_item_count = count($productCollection);?>
                                                    <?php $cateId = $_cate->getId();?>
                                                    <?php if($_item_count > 0): ?>
                                                        <li>
                                                            <a href="<?php echo $this->getUrl("catalogsearch/result")."?cat=$cateId&q=1"?>">
                                                                <label><?php echo $_cate->getName()." ($_item_count)" ?></label>
                                                            </a>
                                                        </li>
                                                    <?php endif; ?>
                                                <?php endif ?>
                                                <?php endforeach ?>
                                            </ul>
                                        <?php endif ?>
                                    </div>
                                </div>
                        </div>

                        <div class="search-by-category mar5">

                                <div class="lblhead border-t-l-r">
                                    <h3><?php echo $this->__("Search Unit") ?></h3>
                                </div>
                                <div class="content-category2">
                                    <div class="item first">
                                        <label> <?php echo $this->__("NBS Part #") ?></label>
                                        <input type="text" name="sku" id="sku"/>
                                        <a class="btn-update" id="sku_search" href="javascript:void(0)" ><?php echo $this->__("Search") ?></a>
                                    </div>
                                    <div class="item">
                                        <label> <?php echo $this->__("Model #") ?></label>
                                        <input  type="text" name="model" id="model" />
                                        <a class="btn-update" id="model_search" href="javascript:void(0)"><?php echo $this->__("Search") ?></a>
                                    </div>
                                    <div class="item">
                                        <label> <?php echo $this->__("OEM #") ?></label>
                                        <input  type="text" id="oem"/>
                                        <a class="btn-update" href="javascript:void(0)" id="oem_search"><?php echo $this->__("Search") ?></a>
                                    </div>
                                </div>
                        </div>

                </div>
            </div>
             <script type="text/javascript">

                jQuery(document).ready(function(){

                    jQuery('.jcrollbar').jScrollPane();
                    var url =  jQuery("#url_home").val();
                    jQuery("a#sku_search").unbind("click").bind("click",function(){
                        jQuery(".amshopby-overlay").remove();
                        if(jQuery("#sku").val()==""){
                            alert("please input NBS Part #");
                            return;
                        }

                        url = url + "?sku=" + jQuery("#sku").val();
                        window.location = url;
                    });
                    jQuery("a#model_search").unbind("click").bind("click",function(){

                        jQuery(".amshopby-overlay").remove();
                        if(jQuery("#model").val()==""){
                            alert("please input Model #");
                            return;
                        }

                        url = url + "?model=" + jQuery("#model").val();
                        window.location = url;
                   });
                    jQuery("a#oem_search").unbind("click").bind("click",function(){

                        jQuery(".amshopby-overlay").remove();
                        if(jQuery("#oem").val()==""){
                            alert("please input OEM #");
                            return;
                        }

                        url = url + "?oem=" + jQuery("#oem").val();
                        window.location = url;
                   });

                });

            </script>
            <div class="result-product">
                <div class="page-title">
                </div>
                <p class="note-msg">
                    <?php echo $this->__("There is no result for your search") ?>
                </p>
            </div>
            <input type="hidden" id="url_home" value="<?php echo $this->getUrl("home/index/search")?>" />
        </div>
        
    <div class="clear"></div>
    
</div>





